package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.impl.ClientDAO;
import com.ecommerce.dal.dao.impl.ClientHistoryDAO;
import com.ecommerce.dal.entity.Client;
import com.ecommerce.dal.entity.ClientHistory;
import com.ecommerce.dal.entity.Company;
import com.ecommerce.dal.entity.Rank;
import com.ecommerce.dal.service.IClientManagerService;


@Service("clientManagerService")
public class ClientManagerService implements IClientManagerService {

	@Autowired
	ClientDAO clientDAO;
	@Autowired
	ClientHistoryDAO clientHistoryDAO;
	@Override
	public Client retrieveClient(long clientId) {
		return clientDAO.findByClientId(clientId);
	}

	@Override
	public Client retrieveClient(String clientUserName) {
		return clientDAO.findByClientName(clientUserName);
	}

	@Override
	public void saveClient(Client client) {
		clientDAO.save(client);
		
	}

	@Override
	public List<Client> retrieveAllClients() {
		return clientDAO.findAllClients();
	}

	@Override
	public int retrieveClientState(long clientId) {
		return clientDAO.findClientStateById(clientId);
	}

	@Override
	public Client retrieveMembershipCardClient(long membershipcardId) {
		return clientDAO.findByMembershipCard(membershipcardId);
	}

	@Override
	public int retrieveClientState(String clientUserName) {
		return clientDAO.findClientStateByUserName(clientUserName);
	}
	@Override
	public Rank retrieveClientRank(long clientId) {
		return clientDAO.findClientRankById(clientId);
	}
	@Override
	public Rank retrieveClientRank(String clientUserName) {
		return clientDAO.findClientRankByUserName(clientUserName);
	}


	@Override
	public List<ClientHistory> retrieveClientHistory(long clientId) {
		return clientHistoryDAO.findByClientId(clientId);
	}

	@Override
	public void saveClientHistory(ClientHistory clientHistory) {
		clientHistoryDAO.save(clientHistory);
		
	}

	@Override
	public List<ClientHistory> retrieveClientHistory(String clientUserName) {
		return clientHistoryDAO.findByClientUserName(clientUserName);
	}

	@Override
	public Company retrieveClientCompany(long clientId) {
		return clientDAO.findClientCompanyById(clientId);
	}

	@Override
	public Company retrieveClientCompany(String clientUserName) {
		return clientDAO.findClientCompanyByUserName(clientUserName);
	}

	

	

	@Override
	public void updateClient(Client client) {
		clientDAO.update(client);
		
	}

	@Override
	public void deleteClient(Client client) {
		clientDAO.delete(client);
		
	}

	@Override
	public boolean checkIfCustomer(long clientId) {
		return clientDAO.checkIfCustomer(clientId);
	}

	@Override
	public boolean checkIfExists(long clientId) {
		return clientDAO.checkClientId(clientId);
	}

	@Override
	public List<Client> retrieveSponsorClients() {
		return clientDAO.findSponsorClients();
	}

	@Override
	public List<Client> retrieveVerifiedClients() {
		return clientDAO.findVerifiedClients();
	}

	@Override
	public List<Client> retrieveNonVerifiedClients() {
		return clientDAO.findNonVerifiedClients();
	}

	@Override
	public boolean isVerifiedClient(long clientId) {
		return clientDAO.isVerified(clientId);
	}




}
